//     define(['jquery', 'bootstrap', 'backend', 'table', 'form','echarts', 'echarts-theme','bootstrap-daterangepicker'], function ($, undefined, Backend, Table, Form,daterangepicker) {
// console.log(Table);
//     var Controller = {
//         index: function () {
//             var start =Moment().startOf('day');
//             var end = Moment().endOf('day');
//             function cb(start, end) {
//                 $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
//             }
//             var ranges = {};
//             ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
//             ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
//             ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
//             ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
//             ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
//             ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
//             $('#reportrange').daterangepicker({
//                 startDate: start,
//                 endDate: end,
//                 ranges: ranges
//             }, cb);


//             cb(start, end);
//             Controller.api.bindevent();
//         },
//     }

//     return Controller;
// });

define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-theme', 'bootstrap-daterangepicker'], function ($, undefined, Backend, Table, Form, Echarts) {
    var Controller = {
        index: function () {
            $("#reportrange").daterangepicker({
                timePicker: true, // 启用时间选择
                timePickerSeconds: true, // 启用秒选择
                autoUpdateInput: false, // 自动更新输入框值
                locale: {
                    format: 'YYYY-MM-DD HH:mm:ss', // 日期时间格式
                    customRangeLabel: "自定义",
                    applyLabel: "确认",
                    cancelLabel: "重置"
                },
                ranges: {
                    '今天': [Moment().startOf('day'), Moment().endOf('day')],
                    '昨天': [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')],
                    '最近7天': [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')],
                    '最近30天': [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')],
                    '本月': [Moment().startOf('month'), Moment().endOf('month')],
                    '上月': [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')]
                }
            });
           // $('#reportrange span').html(Moment().startOf('day').format('YYYY-MM-DD HH:mm:ss') + ' - ' + Moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'));
            // 监听选择事件
            $('#reportrange').on('apply.daterangepicker', function (ev, picker) {
                console.log(picker);
                $('#reportrange span').html(picker.startDate.format('YYYY-MM-DD HH:mm:ss') + ' - ' + picker.endDate.format('YYYY-MM-DD HH:mm:ss'));
                // $(this).val(picker.startDate.format('YYYY-MM-DD HH:mm:ss') + ' - ' + picker.endDate.format('YYYY-MM-DD HH:mm:ss'));

                $('#s001').val(picker.startDate.format('YYYY-MM-DD HH:mm:ss'));
                $('#s002').val(picker.endDate.format('YYYY-MM-DD HH:mm:ss'));
            });

            $('#reportrange').on('cancel.daterangepicker', function (ev, picker) {
                console.log(picker);

                $('#reportrange span').html(Moment().startOf('day').format('YYYY-MM-DD HH:mm:ss') + ' - ' + Moment().endOf('day').format('YYYY-MM-DD HH:mm:ss'));
            });
            //订单
            var myOrderChart = Echarts.init(document.getElementById('order'));
            var orderOption = {

                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['商品订单', '服务订单', '卡项订单'],
                    bottom: 0,
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '10%',
                    containLabel: true
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    //data: ['02-02', '02-03', '02-04', '02-05', '02-06', '02-07', '02-08']
                    data: Config.column
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: '商品订单',
                        type: 'line',
                        //data: [120, 132, 101, 134, 90, 230, 210],
                        data: Config.orderdata,
                        itemStyle: {
                            color: '#dcab83'
                        }
                    },
                    {
                        name: '服务订单',
                        type: 'line',
                        //data: [300, 500, 400, 450, 474, 480, 410],
                        data: Config.orderdata2,
                        itemStyle: {
                            color: '#e8cd8c'
                        }
                    },
                    {
                        name: '卡项订单',
                        type: 'line',
                       // data: [400, 600, 430, 480, 500, 550, 650],
                       data: Config.orderdata3,
                        itemStyle: {
                            color: '#da7a5f'
                        }
                    },

                ]
            };
            myOrderChart.setOption(orderOption);
            //销售
            var mySaleChart = Echarts.init(document.getElementById('sale'));
            var saleOption = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                legend: {
                    data: ['商品金额', '服务金额', '卡项金额'],
                    bottom: 0 // 放置在底部
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '10%',
                    containLabel: true
                },
                xAxis: {
                    type: 'category',
                    //data: ['02-02', '02-03', '02-04', '02-05', '02-06', '02-07', '02-08'],
                    data: Config.column,
                    axisLabel: {
                        interval: 0, // 强制显示所有标签
                        rotate: 30  // 旋转标签，防止过长
                    }
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: '商品金额',
                        type: 'bar',
                       // data: [120, 132, 101, 134, 90, 230, 210],
                       data: Config.order_sdata,
                        itemStyle: {
                            color: '#f39423'
                        }
                    },
                    {
                        name: '服务金额',
                        type: 'bar',
                       // data: [220, 182, 191, 234, 290, 330, 310],
                       data: Config.order_sdata2,
                        itemStyle: {
                            color: '#f8c68a'
                        }
                    },
                    {
                        name: '卡项金额',
                        type: 'bar',
                       // data: [150, 232, 201, 154, 190, 330, 410],
                       data: Config.order_sdata3,
                        itemStyle: {
                            color: '#f5a544'
                        }
                    }
                ]
            };
            mySaleChart.setOption(saleOption);




        }
    };
    return Controller;
});